package br.com.moxeon.view.composer;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.zkoss.zk.ui.Component;

import br.com.moxeon.control.BankAccountController;
import br.com.moxeon.control.CashierCheckController;
import br.com.moxeon.model.enums.PersonType;
import br.com.moxeon.model.financialaccounts.BankAccount;
import br.com.moxeon.model.financialitems.CashierCheck;
import br.com.vexillum.util.ReflectionUtils;
import br.com.vexillum.util.SpringFactory;

@SuppressWarnings("serial")
@org.springframework.stereotype.Component
@Scope("prototype")
public class CashierCheckComposer extends CheckComposer<CashierCheck, CashierCheckController>{
	
	@Override
	public void doAfterCompose(Component comp) throws Exception{
		super.doAfterCompose(comp);
		loadBinder();
	}
	
	@Override
	public CashierCheckController getControl() {
		return SpringFactory.getController("cashierCheckController", CashierCheckController.class, ReflectionUtils.prepareDataForPersistence(this));
	}

	@Override
	public CashierCheck getEntityObject() {
		CashierCheck check = new CashierCheck();
		setHolderDates(check);
		return check;
		
	}
	
	private void setHolderDates(CashierCheck check)
	{
		check.setHolder("Mega Projetos");
		check.setCgc("12123.123.1.32.12");
		check.setHolderType(PersonType.PESSOA_JURIDICA);
	}
			
	@Override
	protected String getUpdatePage() {
		return "/paginas/cheque/cheque_proprio/modalCadastrar.zul";
	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public List getAccounts(){
		List list = (ArrayList<BankAccount>) SpringFactory.getController("bankAccountController", BankAccountController.class, null).listAll().getList();		return list;
	}
	
}